Skip to content

to display length/shape #288

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed

to display length/shape #288

wants to merge 1 commit into from

Conversation

qige96
Copy link

@qige96 qige96 commented Aug 30, 2024

Displays the size of an Sized variable before displaying its value, such as np.ndarray, torch.Tensor. Can benefit ML/AI programming, as well as other programming that works heavily on large collections. Addressing microsoft/debugpy#1525, microsoft/debugpy#1191, etc.

screenshot

Displays the size of an Sized variable before displaying its value, such as np.ndrray, torch.Tensor. Can benefit ML/AI programming, as well as other programming that works heavily on large collections. ddressing #1525, #1191, #4244, etc (issues of debugpy).
@fabioz
Copy link
Owner

fabioz commented Oct 5, 2024

Thank you very much for the PR.

Do you think you can create a simple test for it?

You can add it to test_debugger_json.py

Some references that do something like you should be testing here (which you can use as a template for the new test) would be : test_pandas, test_stack_and_variables_dict.

@fabioz
Copy link
Owner

fabioz commented Oct 5, 2024

One thing I noticed is that this will change things as other containers such as list/tuple/etc.

The current display is:

<class 'list'>: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,

and with the change it'd be:

len: 50, value: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9,

I think the type info shouldn't be changed on those cases... Maybe instead of customizing something as generic as "anything with a __len__", it could be a bit more scoped to the actual types you are interested in?

-- I'm also a bit worried that we don't have support for priorities in the current mechanism, so, something so generic could override other representations that are more scoped.

@qige96
Copy link
Author

qige96 commented Oct 17, 2024

Hi fabioz, you are right, perhaps using the Sized type is too generic, leading to an over design. But I think displaying len/shape for np.array and torch.tensor would be super useful for us AL/ML people. I will make a new PR with more restricted code, equipped with tests.

@codeJRV
Copy link

codeJRV commented May 23, 2025

Hi @fabioz , @qige96 ... I made a followup PR doing the same, as I think this would hugely benefit the ML/AI community.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants